using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    HttpCookie cookie;

    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = "The Time of Server is: " + DateTime.Now.TimeOfDay;
        setLoginControls();
    }



    private void setLoginControls()
    {
        logout.Visible = false;
        if (CheckLogin())
        {
            if (Request.Params["logout"] == "true")
            {
                Session["userID"] = null;
                lblGreeting.Text = "The user is not logged in.";
                loginLink.Visible = true;

            }//end if
            else
            {
                lblGreeting.Visible = true;
                lblGreeting.Text = "You are logged in as [<span id=\"blue\">" + Session["userID"].ToString() + "("+ Session["AccountType"].ToString() + ")" + "</span>] ";
                loginLink.Visible = false;
                logout.Visible = true;

            }//end else
        }//end if

    }//end setLoginControls

    public bool CheckLogin()
    {
        string userID = (string)Session["userID"];
        if (userID == null) { return false; }
        if (userID.CompareTo("") == 0) { return false; }
        return true;
    }

    protected void loginLink_Click(object sender, EventArgs e)
    {
        Response.Redirect("Login.aspx");
    }

    protected void logout_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx?logout=true");
    }
    
}
